package package06章_面向对象编程_基础._08constructor;/**
 * ClassName: Person
 * Package: package06章_面向对象编程_基础._08constructor
 * Description:
 *
 * @Author lys
 * @Create 2024/2/17 10:31
 * @Version 1.0
 */

/**
 * @author lys
 * @version 1.0
 * @description: TODO
 * @date 2024/2/17 10:31
 */
public class Person {
    //属性
    String name;
    int age;


    //构造器
    public Person() {
        System.out.println("Person()....");
    }

    //声明其它的构造器
    public Person(int a) {
        age = a;
    }

    public Person(String n) {
        name = n;
    }

    public Person(String n, int a) {
        name = n;
        age = a;
    }

    //方法
    public void eat() {
        System.out.println("人吃饭");
    }

    public void sleep(int hour) {
        System.out.println("每天睡眠" + hour + "小时");
    }

}
